package com.example.ticket.service.impl;


import com.example.ticket.entity.TicketFile;
import com.example.ticket.mapper.FileMapper;
import com.example.ticket.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

@Service
public class FileServiceimpl implements FileService {

    @Autowired
    FileMapper fileMapper;

    @Autowired
    RedisTemplate redisTemplate;

    @Override
    public TicketFile insertFile (TicketFile ticketFile){
        int res=fileMapper.insertFile(ticketFile);
        if(res==1){
            redisTemplate.opsForValue().set("ticketFile_"+ticketFile.getTicketId(),ticketFile,20, TimeUnit.MINUTES);
        }
        return ticketFile;
    }
}
